﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace project2
{
    class Program
    {
        static void Main(string[] args)
        {
            //设置一个list保存图形对象
            List<shape> list = new List<shape>();
            Random r = new Random();
            int allarea = 0;
            //创建工厂
            RectangleFactory p1 = new RectangleFactory();
            SquareFactory p2 = new SquareFactory();
            CircleFactory p3 = new CircleFactory();
            for (int i = 0; i<10 ; i++)
            {
                int choice = r.Next(3);
                //0为创建长方形，1为创建正方形，2为创建圆形
                switch (choice)
                {
                    case 0:
                        list.Add(p1.createshape());
                        Console.WriteLine("创建的" + (i+1)+ "个图形为长方形");
                        break;
                    case 1:
                        list.Add(p2.createshape());
                        Console.WriteLine("创建的" + (i+1) + "个图形为正方形");
                        break;
                    case 2:
                        list.Add(p3.createshape());
                        Console.WriteLine("创建的" + (i+1) + "个图形为圆形");
                        break;
                }
            }
            for (int j = 0; j < 10; j++)
            {
                allarea = allarea + list[j].getarea();
            }
            Console.WriteLine("总面积为" + allarea);
        }
    }
}
